﻿/*****************************************************************//**
 * @file    FITKAcousticsVTKGraphObjectMergedData.h
 * @brief   Graph object base for merged data.
 *  
 * @author  ChengHaotian (yeguangbaozi@foxmail.com)
 * @date    2024-11-19
 *********************************************************************/

#ifndef __FITKACOUSTICSVTKGRAPHOBJECTMERGEDDATA_H__
#define __FITKACOUSTICSVTKGRAPHOBJECTMERGEDDATA_H__

#include "FITKAcousticsVTKGraphObject3DPost.h"

#include "FITKAcousticsVTKGraphAdaptorAPI.h"

// Forward declaration
class vtkCompositeDataGeometryFilter;
class vtkExtractBlock;
class vtkMultiBlockDataSet;

class FITKAcousticsVTKGraphActor;

namespace Acoustics
{
    class FITKAcousticsSEAModel;
    class FITKAbstractSEASubSys;
}

namespace Exchange
{
    class FITKAcousticsVTKGraphObjectSEASelectMergedData;
}

namespace Exchange
{
    /**
     * @brief   Graph object base for merged data.
     * @author  ChengHaotian (yeguangbaozi@foxmail.com)
     * @date    2024-11-19
     */
    class FITKACOUSTICSGRAPHADAPTORAPI FITKAcousticsVTKGraphObjectMergedData : public FITKAcousticsVTKGraphObject3DPost
    {
        // Regist
        FITKGraphObjectRegist(FITKAcousticsVTKGraphObjectMergedData, FITKAcousticsVTKGraphObject3DPost);
        FITKCLASS(Exchange, FITKAcousticsVTKGraphObjectMergedData);

    public:
        /**
         * @brief   Constructor.
         * @param   dataObj: The data object
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-19
         */
        FITKAcousticsVTKGraphObjectMergedData(Core::FITKAbstractDataObject* dataObj);

        /**
         * @brief   Destructor.[virtual]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-19
         */
        virtual ~FITKAcousticsVTKGraphObjectMergedData();

        /**
         * @brief   Update all graph actors.[virtual][override]
         * @param   forceUpdate: Force update[default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-19
         */
        virtual void update(bool forceUpdate = false) override;

        /**
         * @brief   Update the visibility with data object's visibility.[virtual][override]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-19
         */
        virtual void updateVisibility() override;

        /**
         * @brief   Update all graph actors by the given data id.[virtual][override]
         * @param   dataId: The data id need to be update
         * @param   forceUpdate: Force update[default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-19
         */
        virtual void updateById(int dataId, bool forceUpdate = false) override;

        /**
         * @brief   Update all graph actors by the given data ids.[virtual][override]
         * @param   dataIds: The data ids need to be update
         * @param   forceUpdate: Force update[default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-19
         */
        virtual void updateByIds(QList<int> dataIds, bool forceUpdate = false) override;

        /**
         * @brief   Highlight the graph actors.[virtual][override]
         * @param   type: The shape type need to be highlighted[default]
         * @param   color: The given color for highlighting this time[default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-19
         */
        virtual void highlight(FITKAcousticsVTKCommons::ShapeType type = FITKAcousticsVTKCommons::ShapeTypeNone, QColor color = QColor()) override;

        /**
         * @brief   Dis-highlight the graph actors.[virtual][override]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-19
         */
        virtual void disHighlight() override;

        /**
         * @brief   Advanced highlight mode for highlighting part of the graph actors.[virtual][override]
         * @param   type: The type of the model need to be highlighted
         * @param   indice: The given indice of the model component need to be highlight
         * @param   color: The given color for highlighting this time[default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-19
         */
        virtual void advanceHighlight(FITKAcousticsVTKCommons::ShapeType type, QVector<int> indice, QColor color = QColor()) override;

        /**
         * @brief   Dis-highlight the graph actors if the graph object is in advanced highlighting mode.[virtual][override]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-19
         */
        virtual void disAdvanceHighlight() override;

        /**
         * @brief   Set if the graph object pickable mode.[virtual][override]
         * @param   mode: The pickable mode
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-19
         */
        virtual void setPickMode(FITKAcousticsVTKCommons::ShapePickMode mode) override;

        /**
         * @brief   Get the shape id by the given shape type and VTK cell id.[virtual][override]
         * @param   vtkId: The VTK point or cell id in shape data
         * @param   topAbsShapeType: The shape type of the given ID( the same as TopAbs_ShapeEnum )
         * @return  The shape id
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-19
         */
        virtual int getShapeIdByVTKCellId(int vtkId, FITKAcousticsVTKCommons::ShapeMeshAbsEnum topAbsShapeType) override;

    protected:
        /**
         * @brief   Intialize.[virtual]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-19
         */
        virtual void init();

        /**
         * @brief   Generate the multi block dataset for the sub-systems.[pure virtual]
         * @return  Is the data valid
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-19
         */
        virtual bool generateDataSet() = 0;

        /**
         * @brief   Generate the actor with the sub-system data.[virtual]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-19
         */
        virtual void generateGraph();

    protected:
        /**
         * @brief   The highlightor of the merged dataset.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-19
         */
        FITKAcousticsVTKGraphObjectSEASelectMergedData* m_highlightSelector{ nullptr };

        /**
         * @brief   The filter for merging multi block dataset.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-19
         */
        vtkCompositeDataGeometryFilter* m_comp2Poly{ nullptr };
        /**
         * @brief  当前显示的数据组（是全部数据的子集）
         * @author BaGuijun (baguijun@163.com)
         * @date   2024-12-25
         */
        vtkMultiBlockDataSet* m_multiBlockDataSet = nullptr;
        /**
         * @brief   The filter for extracting the blocks of the multi block dataset.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-20
         */
        vtkExtractBlock* m_extractBlock{ nullptr };

        /**
         * @brief   The actor for the grid.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-19
         */
        FITKAcousticsVTKGraphActor* m_fActor{ nullptr };

    };
}   // namespace Exchange

#endif // __FITKACOUSTICSVTKGRAPHOBJECTMERGEDDATA_H__
